#!/usr/bin/python
# -*- coding: utf-8 -*-
#Under the terms of the General Public License v.3
#For more information see LICENSE.txt

#from Element import *
import pygame
from pygame.locals import K_LEFT, K_RIGHT, K_UP, K_DOWN, QUIT, KEYDOWN

class Player (object):

	"""

	:version:
	:author:
	"""

	""" ATTRIBUTES

	 Speed in X

	speedX  (private)

	 Speed in Y

	speedY  (private)

	"""

	def __init__(self,map):
		#Element.__init__(self, image, posX, posY)
		self.map = map
		self.image = pygame.image.load('./data/image/nave1.png').convert_alpha()
		self.rect = self.image.get_rect()
		self.rect.move_ip(0, 0)
		self.pointControl_x = 0
		self.pointControl_y = 0


	def updatePosition(self):
		"""
		 Update the position of the element

		@return  :
		@author
		"""
		keysPressed = pygame.key.get_pressed()
		dx = 0
		dy = 0

		if keysPressed[K_UP]:
			dy -= 2
		elif keysPressed[K_DOWN]:
			dy = 2
		if keysPressed[K_LEFT]:
			dx = -2
		elif keysPressed[K_RIGHT]:
			dx = 2

		if not self.map.cantStep(self.rect.x + dx, self.rect.y):
			if (dx< 0):
				dx += 12
			else:
				dx -= 12

		if not self.map.cantStep(self.rect.x, self.rect.y + dy):
			if (dy < 0):
				dy += 12
			else:
				dy -= 12

		self.rect.move_ip(dx, dy)
		self.map.lookAt(self.rect)

	def showPlayer(self, screen):
		x = self.rect.x - self.map.camera_x - self.pointControl_x
		y = self.rect.y - self.map.camera_y - self.pointControl_y
		screen.blit(self.image, (x, y))

		#def checkBoundColision(self, posX, posY, ):
		#"""
		 #Checks colitions betwen two thinks.

		#@return  :
		#@author
		#"""
	#def setSpeedX(self, speedX):
		#"""

		#@return  :
		#@author
		#"""
		#self.speedX = speedX

	#def setspeedY(self, speedY):
		#"""

		#@return  :
		#@author
		#"""
		#self.speedY = speedY

	#def getSpeedX(self):
		#"""

		#@return int :
		#@author
		#"""
		#return self.speedX = speedX

	#def getSpeedY(self):
		#"""

		#@return int :
		#@author
		#"""
		#return self.speedY = speedY




